home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / include / devices / cd.h < prev    next >
C/C++ Source or Header  |  1996-09-10  |  13KB  |  351 lines

  1. #ifndef DEVICES_CD_H
  2. #define DEVICES_CD_H 1
  3. /*
  4. ** cd.h for ACE Basic
  5. **
  6. ** Note: Translated to ACE by ConvertC2ACE
  7. **       @ MapMeadow Software, Nils Sjoholm
  8. **
  9. **
  10. ** Date: 09/03/95
  11. **
  12. **
  13. */
  14.  
  15. /*
  16. ** This are the StructPointer defines for cd.h
  17. */
  18. #ifndef CDInfoPtr
  19. #define CDInfoPtr ADDRESS
  20. #endif
  21. #ifndef CDTOCPtr
  22. #define CDTOCPtr ADDRESS
  23. #endif
  24. #ifndef CDXLPtr
  25. #define CDXLPtr ADDRESS
  26. #endif
  27. #ifndef LSNMSFPtr
  28. #define LSNMSFPtr ADDRESS
  29. #endif
  30. #ifndef QCodePtr
  31. #define QCodePtr ADDRESS
  32. #endif
  33. #ifndef RMSFPtr
  34. #define RMSFPtr ADDRESS
  35. #endif
  36. #ifndef TOCEntryPtr
  37. #define TOCEntryPtr ADDRESS
  38. #endif
  39. #ifndef TOCSummaryPtr
  40. #define TOCSummaryPtr ADDRESS
  41. #endif
  42. /*
  43. ** End of StructPointer defines for cd.h
  44. */
  45.                      
  46. #include <exec/types.h>
  47. #include <exec/nodes.h>
  48.  
  49.  
  50. /**************************************************************************
  51.  *                                    *
  52.  *   CD Commands                              *
  53.  *                                    *
  54.  **************************************************************************/
  55.  
  56. #define CD_RESET         1
  57. #define CD_READ      2
  58. #define CD_WRITE         3
  59. #define CD_UPDATE        4
  60. #define CD_CLEAR         5
  61. #define CD_STOP      6
  62. #define CD_START         7
  63. #define CD_FLUSH         8
  64. #define CD_MOTOR         9
  65. #define CD_SEEK     10
  66. #define CD_FORMAT       11
  67. #define CD_REMOVE       12
  68. #define CD_CHANGENUM        13
  69. #define CD_CHANGESTATE      14
  70. #define CD_PROTSTATUS       15
  71.  
  72. #define CD_GETDRIVETYPE     18
  73. #define CD_GETNUMTRACKS     19
  74. #define CD_ADDCHANGEINT     20
  75. #define CD_REMCHANGEINT     21
  76. #define CD_GETGEOMETRY      22
  77. #define CD_EJECT        23
  78.  
  79.  
  80. #define CD_INFO     32
  81. #define CD_CONFIG       33
  82. #define CD_TOCMSF       34
  83. #define CD_TOCLSN       35
  84.  
  85. #define CD_READXL       36
  86.  
  87. #define CD_PLAYTRACK        37
  88. #define CD_PLAYMSF      38
  89. #define CD_PLAYLSN      39
  90. #define CD_PAUSE        40
  91. #define CD_SEARCH       41
  92.  
  93. #define CD_QCODEMSF     42
  94. #define CD_QCODELSN     43
  95. #define CD_ATTENUATE        44
  96.  
  97. #define CD_ADDFRAMEINT      45
  98. #define CD_REMFRAMEINT      46
  99.  
  100.  
  101. /**************************************************************************
  102.  *                                    *
  103.  *   Device Driver Error Codes                        *
  104.  *                                    *
  105.  **************************************************************************/
  106.  
  107. #define CDERR_OPENFAIL       (-1) /* device/unit failed to open   */
  108. #define CDERR_ABORTED        (-2) /* request terminated early         */
  109. #define CDERR_NOCMD      (-3) /* command not supported by device      */
  110. #define CDERR_BADLENGTH      (-4) /* invalid length (IO_LENGTH/IO_OFFSET) */
  111. #define CDERR_BADADDRESS     (-5) /* invalid address (IO_DATA misaligned) */
  112. #define CDERR_UNITBUSY       (-6) /* device opens ok,  but unit is busy    */
  113. #define CDERR_SELFTEST       (-7) /* hardware failed self-test        */
  114.  
  115. #define CDERR_NotSpecified   20   /* general catchall             */
  116. #define CDERR_NoSecHdr       21   /* couldn't even find a sector      */
  117. #define CDERR_BadSecPreamble 22   /* sector looked wrong          */
  118. #define CDERR_BadSecID       23   /* ditto                */
  119. #define CDERR_BadHdrSum      24   /* header had incorrect checksum    */
  120. #define CDERR_BadSecSum      25   /* data had incorrect checksum      */
  121. #define CDERR_TooFewSecs     26   /* couldn't find enough sectors     */
  122. #define CDERR_BadSecHdr      27   /* another "sector looked wrong"    */
  123. #define CDERR_WriteProt      28   /* can't write to a protected disk      */
  124. #define CDERR_NoDisk         29   /* no disk in the drive         */
  125. #define CDERR_SeekError      30   /* couldn't find track 0        */
  126. #define CDERR_NoMem      31   /* ran out of memory            */
  127. #define CDERR_BadUnitNum     32   /* asked for a unit > NUMUNITS      */
  128. #define CDERR_BadDriveType   33   /* not a drive cd.device understands    */
  129. #define CDERR_DriveInUse     34   /* someone else allocated the drive     */
  130. #define CDERR_PostReset      35   /* user hit reset  awaiting doom    */
  131. #define CDERR_BadDataType    36   /* data on disk is wrong type   */
  132. #define CDERR_InvalidState   37   /* invalid cmd under current conditions */
  133.  
  134. #define CDERR_Phase      42   /* illegal or unexpected SCSI phase     */
  135. #define CDERR_NoBoard        50   /* open failed for non-existant board   */
  136.  
  137.  
  138.  
  139. /**************************************************************************
  140.  *                                    *
  141.  * Configuration                              *
  142.  *                                    *
  143.  *   The drive is configured by TagList items defined as follows:     *
  144.  *                                    *
  145.  **************************************************************************/
  146.  
  147. #define TAGCD_PLAYSPEED &H0001
  148. #define TAGCD_READSPEED &H0002
  149. #define TAGCD_READXLSPEED   &H0003
  150. #define TAGCD_SECTORSIZE    &H0004
  151. #define TAGCD_XLECC     &H0005
  152. #define TAGCD_EJECTRESET    &H0006
  153.  
  154.  
  155. /**************************************************************************
  156.  *                                    *
  157.  * Information                                *
  158.  *                                    *
  159.  *  Information/Status structure describes current speed settings     *
  160.  *  for read and play commands,  sector size,  audio attenuation    *
  161.  *  precision,  and drive status.                      *
  162.  *                                    *
  163.  **************************************************************************/
  164.  
  165. STRUCT CDInfo  
  166.                 /*                    Default     */
  167.     SHORTINT   PlaySpeed       /* Audio play speed       (75)    */
  168.     SHORTINT   ReadSpeed       /* Data-rate of CD_READ command   (Max)   */
  169.     SHORTINT   ReadXLSpeed     /* Data-rate of CD_READXL command (75)    */
  170.     SHORTINT   SectorSize      /* Number of bytes per sector     (2048)      */
  171.     SHORTINT   XLECC       /* CDXL ECC enabled/disabled          */
  172.     SHORTINT   EjectReset      /* Reset on eject enabled/disabled        */
  173.     STRING Reserved1 SIZE 8    /*  4*SIZEOF(SHORTINT) */   /* Reserved FOR future expansion          */
  174.  
  175.     SHORTINT   MaxSpeed        /* Maximum speed drive can handle (75,  150)   */
  176.     SHORTINT   AudioPrecision  /* 0 = no attenuator,  1 = mute only,       */
  177.                 /* other = (# levels - 1)             */
  178.     SHORTINT   Status      /* See flags below                */
  179.     STRING Reserved2 SIZE 8    /* 4*SIZEOF(SHORTINT)  */  /* Reserved FOR future expansion          */
  180. END STRUCT 
  181.  
  182.  
  183. /* Flags for Status */
  184.  
  185. #define CDSTSB_CLOSED    0 /* Drive door is closed            */
  186. #define CDSTSB_DISK  1 /* A disk has been detected            */
  187. #define CDSTSB_SPIN  2 /* Disk is spinning (motor is on)          */
  188. #define CDSTSB_TOC   3 /* Table of contents read.  Disk is valid.     */
  189. #define CDSTSB_CDROM     4 /* Track 1 contains CD-ROM data        */
  190. #define CDSTSB_PLAYING   5 /* Audio is playing                */
  191. #define CDSTSB_PAUSED    6 /* Pause mode (pauses on play command)     */
  192. #define CDSTSB_SEARCH    7 /* Search mode (Fast Forward/Fast Reverse)     */
  193. #define CDSTSB_DIRECTION 8 /* Search direction (0 = Forward,  1 = Reverse) */
  194.  
  195. #define CDSTSF_CLOSED    &H0001
  196. #define CDSTSF_DISK  &H0002
  197. #define CDSTSF_SPIN  &H0004
  198. #define CDSTSF_TOC   &H0008
  199. #define CDSTSF_CDROM     &H0010
  200. #define CDSTSF_PLAYING   &H0020
  201. #define CDSTSF_PAUSED    &H0040
  202. #define CDSTSF_SEARCH    &H0080
  203. #define CDSTSF_DIRECTION &H0100
  204.  
  205.  
  206. /* Modes for CD_SEARCH */
  207.  
  208. #define CDMODE_NORMAL   0     /* Normal play at current play speed    */
  209. #define CDMODE_FFWD 1     /* Fast forward play (skip-play forward)*/
  210. #define CDMODE_FREV 2     /* Fast reverse play (skip-play reverse)*/
  211.  
  212.  
  213. /**************************************************************************
  214.  *                                    *
  215.  * Position Information                       *
  216.  *                                    *
  217.  *  Position information can be described in two forms: MSF and LSN   *
  218.  *  form.  MSF (Minutes,  Seconds,  Frames) form is a time encoding.    *
  219.  *  LSN (Logical Sector Number) form is frame (sector) count.     *
  220.  *  The desired form is selected using the io_Flags field of the      *
  221.  *  IOStdReq structure.  The flags and the STRUCT are described    *
  222.  *  below.                                *
  223.  *                                    *
  224.  **************************************************************************/
  225.  
  226. STRUCT RMSF  
  227.  
  228.     BYTE    Reserved        /* Reserved (always zero) */
  229.     BYTE    Minute      /* Minutes (0-72ish)      */
  230.     BYTE    Second      /* Seconds (0-59)         */
  231.     BYTE    Frame       /* Frame   (0-74)         */
  232. END STRUCT 
  233.  
  234. STRUCT LSNMSF  
  235.  
  236.     RMSF MSF        /* Minute,  Second,  Frame  */
  237.     LONGINT   LSN         /* Logical Sector Number  */
  238. END STRUCT 
  239.  
  240.  
  241. /**************************************************************************
  242.  *                                    *
  243.  * CD Transfer Lists                              *
  244.  *                                    *
  245.  *  A CDXL node is a double link node  however only single linkage    *
  246.  *  is used by the device driver.  If you wish to construct a     *
  247.  *  transfer list manually,  it is only neccessary to define the   *
  248.  *  mln_Succ pointer of the MinNode.  You may also use the Exec   *
  249.  *  list functions by defining a List or MinList structure and by     *
  250.  *  using the AddHead/AddTail functions to create the list.  This     *
  251.  *  will create a double-linked list.  Although a double-linked   *
  252.  *  list is not required by the device driver,  you may wish use it    *
  253.  *  for your own purposes.  Don't forget to initialize the        *
  254.  *  the List/MinList before using it!                 *
  255.  *                                    *
  256.  **************************************************************************/
  257.  
  258. STRUCT  CDXL  
  259.  
  260.     MinNode Node         /* double linkage          */
  261.     ADDRESS   Buffer           /* data destination (SHORTINT aligned) */
  262.     LONGINT          Length           /* must be even # bytes        */
  263.     LONGINT          Actual           /* bytes transferred       */
  264.     ADDRESS          IntData          /* interrupt server data segment   */
  265.     ADDRESS   IntCode     /* interrupt server code entry     */
  266. END STRUCT 
  267.  
  268.  
  269. /**************************************************************************
  270.  *                                    *
  271.  * CD Table of Contents                       *
  272.  *                                    *
  273.  *  The CD_TOC command returns an array of CDTOC entries.         *
  274.  *  Entry zero contains summary information describing how many   *
  275.  *  tracks the disk has and the play-time of the disk.        *
  276.  *  Entries 1 through N (N = Number of tracks on disk) contain    *
  277.  *  information about the track.                      *
  278.  *                                    *
  279.  **************************************************************************/
  280.  
  281. STRUCT TOCSummary  
  282.  
  283.     BYTE     FirstTrack  /* First track on disk (always 1)        */
  284.     BYTE     LastTrack   /* Last track on disk            */
  285.     LSNMSF LeadOut     /* Beginning of lead-out track (end of disk) */
  286. END STRUCT 
  287.  
  288.  
  289. STRUCT TOCEntry  
  290.  
  291.     BYTE     CtlAdr      /* Q-Code info          */
  292.     BYTE     Track       /* Track number             */
  293.     LSNMSF Position    /* Start position of this track */
  294. END STRUCT 
  295.  
  296.  
  297. STRUCT CDTOC  
  298.  
  299.     TOCSummary Summary   /* First entry (0) is summary information */
  300.     TOCEntry Entry     /* Entries 1-N are track entries      */
  301. END STRUCT 
  302.  
  303.  
  304.  
  305. /**************************************************************************
  306.  *                                    *
  307.  * Q-Code Packets                             *
  308.  *                                    *
  309.  *  Q-Code packets are only returned when audio is playing.   *
  310.  *  Currently,  only position packets are returned (ADR_POSITION)      *
  311.  *  The other ADR_ types are almost never encoded on the disk     *
  312.  *  and are of little use anyway.  To avoid making the QCode      *
  313.  *  structure a STRUCT,  these other ADR_ structures are not defined.   *
  314.  *                                    *
  315.  **************************************************************************/
  316.  
  317. STRUCT QCode  
  318.  
  319.     BYTE     CtlAdr     /* Data type / QCode type       */
  320.     BYTE     Track  /* Track number         */
  321.     BYTE     Index  /* Track subindex number        */
  322.     BYTE     Zero       /* The "Zero" byte of Q-Code packet */
  323.     LSNMSF TrackPosition  /* Position from start of track     */
  324.     LSNMSF DiskPosition   /* Position from start of disk      */
  325. END STRUCT 
  326.  
  327.  
  328. #define CTLADR_CTLMASK &HF0   /* Control field */
  329.  
  330. #define CTL_CTLMASK    &HD0   /* To be ANDed with CtlAdr before compared  */
  331.  
  332. #define CTL_2AUD       &H00   /* 2 audio channels without preemphasis     */
  333. #define CTL_2AUDEMPH   &H10   /* 2 audio channels with preemphasis    */
  334. #define CTL_4AUD       &H80   /* 4 audio channels without preemphasis     */
  335. #define CTL_4AUDEMPH   &H90   /* 4 audio channels with preemphasis    */
  336. #define CTL_DATA       &H40   /* CD-ROM Data                  */
  337.  
  338. #define CTL_COPYMASK   &H20   /* To be ANDed with CtlAdr before compared  */
  339.  
  340. #define CTL_COPY       &H20   /* When true,  this audio/data can be copied */
  341.  
  342. #define CTLADR_ADRMASK &H0F   /* Address field                */
  343.  
  344. #define ADR_POSITION   &H01   /* Q-Code is position information   */
  345. #define ADR_UPC        &H02   /* Q-Code is UPC information (not used)     */
  346. #define ADR_ISRC       &H03   /* Q-Code is ISRC (not used)        */
  347. #define ADR_HYBRID     &H05   /* This disk is a hybrid disk       */
  348.  
  349.  
  350. #endif
  351.